home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / keymaptest / keymaptst.p < prev   
Encoding:
Text File  |  2000-06-23  |  3.1 KB  |  109 lines

  1. {
  2.     File:        KeyMapTst.p
  3.  
  4.     Contains:    
  5.  
  6.     Written by: Cameron Birse    
  7.  
  8.     Copyright:    Copyright © 1984-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/6/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22.  
  23. }
  24. PROGRAM KeyMapTst;
  25. {$load KeyLoad}
  26. uses Memory,QuickDraw,Events,Windows;
  27.    
  28.  
  29. VAR
  30.     i,x,y : Integer;
  31.     myKeyMap,oldKeyMap : KeyMap;
  32.     quit,yes : boolean;
  33.     MyRect : rect;
  34.  
  35.  
  36.     {------------------------------------------------------------------------------------}
  37. {
  38.   FUNCTION SysEnvirons(versionRequested: INTEGER; VAR theWorld: SysEnvRec): OSErr;
  39.   
  40.   INLINE $205f,$301f, $A090, $3e80;
  41.   
  42.   PROCEDURE ShutDwnStart;
  43.     INLINE $3F3C,$0002,$A895;
  44.  
  45. }
  46.     {------------------------------------------------------------------------------------}
  47.  
  48.                                                     
  49. BEGIN                              {main PROGRAM}
  50.     InitGraf(@qd.thePort);                {initialize QuickDraw}
  51.     FlushEvents(everyEvent, 0);        {call OS Event Mgr to discard any previous events}
  52.     InitWindows;                       {initialize Window Manager}
  53.     InitCursor;                        {call QuickDraw to make cursor (pointer) an arrow}
  54.  
  55. {PROCEDURE WWInit(numLines, numCharsPerLine: INTEGER);}
  56.  
  57.     {WWInit(25,65);                initialize WritelnWindow with default window}
  58.  
  59. {PROCEDURE WWNew(bounds: Rect; windowTitle: Str255; goAway: BOOLEAN; visible: BOOLEAN;
  60.                 outputFont, outputSize: INTEGER);}
  61.                 
  62.     Myrect.top := qd.ScreenBits.bounds.top+40;
  63.     Myrect.left := qd.ScreenBits.bounds.left+4;
  64.     Myrect.bottom := qd.ScreenBits.bounds.bottom-4;
  65.     Myrect.right := qd.ScreenBits.bounds.right-4;
  66.     
  67.     //WWNew(MyRect, 'A Window, eh?', true, true, 1,9);
  68.  
  69.  
  70.     quit := false;
  71.     yes := false;
  72.     writeln ('KeyMap :');
  73.     for i := 0 to 127 do
  74.     begin
  75.         if myKeyMap[i] then write('1')
  76.         else write('0');
  77.         if i = 63 then writeln ('');
  78.         oldKeyMap[i] := myKeyMap[i];
  79.         if button then quit := true;
  80.     end;
  81.     writeln ('');
  82.     repeat
  83.         if button then quit := true;
  84.         GetKeys (myKeyMap);
  85.         for x := 0 to 127 do
  86.         begin
  87.             if myKeyMap[x] <> oldKeyMap[x] then 
  88.             begin
  89.                 yes := true;
  90.                 y := x;
  91.             end;
  92.         end;    
  93.         if yes then
  94.         begin
  95.             writeln ('Bit # ',y,' changed, KeyMap =');
  96.             yes := false;
  97.             for i := 0 to 127 do
  98.             begin
  99.                 if myKeyMap[i] then write('1')
  100.                 else write('0');
  101.                 if i = 63 then writeln ('');
  102.                 oldKeyMap[i] := myKeyMap[i];
  103.                 if button then quit := true;
  104.             end;
  105.             writeln (' end');
  106.         end;
  107.     until quit;    
  108.  
  109. END.